home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / graphpp.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  5KB  |  185 lines

  1. #ifndef __GRAPHPP
  2. #ifndef __GRAPHICS_H
  3. #include <graphics.h>
  4. #endif
  5. #ifndef __GEOM
  6. #include "geom.h"
  7. #endif
  8. #define __GRAPHPP
  9.  
  10. /*struct palettetype {
  11.     unsigned char size;
  12.     signed char colors[MAXCOLORS+1];
  13. };
  14.  
  15. struct linesettingstype {
  16.     int linestyle;
  17.     unsigned upattern;
  18.     int thickness;
  19. };  */
  20.  
  21. /***************** OOP - versions of graphics.h structures : ************/
  22.  
  23. struct Linesettingstype :linesettingstype {
  24.        Linesettingstype(int style=SOLID_LINE, int width=NORM_WIDTH)
  25.       {linestyle=style;thickness= width;upattern=0;}
  26.        Linesettingstype(const linesettingstype& l) : linesettingstype(l)
  27.       { }
  28.  
  29.  
  30. };
  31. /*
  32.  
  33. struct textsettingstype {
  34.     int font;
  35.     int direction;
  36.     int charsize;
  37.     int horiz;
  38.     int vert;
  39. };
  40. */
  41. struct Textsettingstype: textsettingstype{
  42.      Textsettingstype(int Font,int Size=1,int Direction = HORIZ_DIR,
  43.                       int Horiz=-1,int Vert=-1)
  44.     {
  45.        if(Horiz <0 || Vert <0) gettextsettings(this) ;
  46.        if(Horiz >=0) horiz=Horiz;
  47.        if(Vert >=0) vert=Vert;
  48.        font=Font; charsize=Size; direction=Direction;
  49.    }
  50.     Textsettingstype(const textsettingstype& tset) : textsettingstype(tset)
  51.      {}
  52. };
  53.  
  54.  
  55. /*
  56. struct fillsettingstype {
  57.     int pattern;
  58.     int color;
  59. };
  60.  
  61. struct pointtype {
  62.     int x, y;
  63. };
  64.  */
  65.  
  66. /*
  67. struct viewporttype {
  68.     int left, top, right, bottom;
  69.     int clip;
  70. };
  71. */
  72.  
  73.  struct Viewporttype: viewporttype {
  74.     Viewporttype(int Left,int Top)
  75.         {
  76.         left=Left;top=Top;
  77.         right=getmaxx();
  78.         bottom=getmaxy();
  79.         clip=0;
  80.          }
  81.     Viewporttype(int Left,int Top,int Right,int Bottom,int Clip=0)
  82.       {left=Left;top=Top;right=Right; bottom=Bottom; clip=Clip;}
  83.     Viewporttype(const rect& r,int Clip=0)
  84.      {left=r.left();top=r.top();right=r.right();bottom=r.bottom();
  85.       clip=Clip; }
  86.     Viewporttype(const viewporttype& vp) : viewporttype(vp)
  87.       { }
  88.     operator rect() {return rect(left,top,right,bottom);}
  89. };
  90.  
  91. /*
  92. struct arccoordstype {
  93.     int x, y;
  94.     int xstart, ystart, xend, yend;
  95. };
  96.  
  97.   */
  98.  
  99. /**************** Overloaded functions from graphics.h : ************/
  100.  
  101. inline linesettingstype getlinesettings()
  102.   {linesettingstype lset;getlinesettings(&lset); return lset; }
  103.  
  104. inline void setlinestyle(Linesettingstype lset)
  105.   { setlinestyle(lset.linestyle,lset.upattern,lset.thickness); }
  106.  
  107.  
  108. inline void settextstyle(const Textsettingstype& tset)
  109.    {
  110.      settextstyle(tset.font,tset.direction,tset.charsize);
  111.      }
  112.  
  113. inline textsettingstype gettextsettings()
  114.     {  textsettingstype tset;
  115.     gettextsettings(&tset); return tset;
  116.     }
  117.  
  118. inline void rectangle(const rect& r)
  119.   {rectangle(r.left(),r.top(),r.right(),r.bottom()); }
  120.  
  121. inline void bar(const rect& r)
  122.   {bar(r.left(),r.top(),r.right(),r.bottom()); }
  123.  
  124. inline void bar3d(const rect& r,int depth=0,int topflag=0)
  125.   {bar3d(r.left(),r.top(),r.right(),r.bottom(),depth,topflag); }
  126.  
  127. inline unsigned imagesize(const rect& box)
  128.   {return imagesize(box.left(),box.top(),box.right(),box.bottom()); }
  129.  
  130. inline void getimage(const rect& box,void far * bitmap)
  131.   { getimage(box.left(),box.top(),box.right(),box.bottom(),bitmap); }
  132.  
  133. inline void putimage(loc where,void far * bitmap,int op=COPY_PUT)
  134.   { putimage(where.X,where.Y,bitmap,op); }
  135.  
  136. inline void moveto(loc where)
  137.  { moveto(where.X,where.Y);}
  138. inline void moverel(loc by)
  139.  { moverel(by.X,by.Y);}
  140.  
  141. inline void  line( loc from,loc to)
  142.   { line(from.X,from.Y,to.X,to.Y);}
  143. inline void  linerel(loc by)
  144.    {linerel(by.X,by.Y);}
  145. inline void  lineto(loc to)
  146.    {lineto(to.X,to.Y);}
  147.  
  148. inline void putpixel(loc at,int color)
  149.   {putpixel(at.X,at.Y,color);}
  150.  
  151. inline int getpixel(loc at)
  152.   {return getpixel(at.X,at.Y);}
  153.  
  154. inline void setviewport(const Viewporttype& vp)
  155.      {setviewport(vp.left,vp.top,vp.right,vp.bottom,vp.clip); }
  156. inline void setviewport(const rect& vpr,int clip)
  157.      {setviewport(vpr.left(),vpr.top(),vpr.right(),vpr.bottom(),clip); }
  158.  
  159. inline viewporttype getviewsettings()
  160.      { viewporttype vp; getviewsettings(&vp); return vp;}
  161.  
  162. /*************  Functions with new names: **********************/
  163.  
  164.  inline loc getCP()
  165.   {return loc(getx(),gety());}
  166.  
  167.  inline loc screensize()
  168.   {return loc(getmaxx(),getmaxy());}
  169.  
  170.  inline void outtextat(loc at,char far * textstring)
  171.   {outtextxy(at.X,at.Y,textstring);}
  172.  
  173.  inline loc textdimensions(char far * textstring)
  174.   {return loc(textwidth(textstring),textheight(textstring));}
  175.  
  176. inline void restoretextsettings(const Textsettingstype& tset)
  177.    {
  178.      settextstyle(tset.font,tset.direction,tset.charsize);
  179.      settextjustify(tset.horiz,tset.vert);
  180.     }
  181.  
  182.  
  183. #endif
  184.  
  185.